const mysql = require('mysql');
const connection = mysql.createConnection({
  host: '127.0.0.1',
  // port: 3306,
  user: 'root',
  password: 'root',
  database: 'albx33'
});

module.exports = {
  getAdminCategories (callback){
    let sql = `SELECT * FROM categories`;
    connection.query(sql,(err,result)=>{
      callback(err,result);
    });
  },
  addNewCategories(data,callback){
    let sql = `INSERT into categories SET \`NAME\`='${data.name}',classname='${data.classname}',slug='${data.slug}'`;
    connection.query(sql,(err,result)=>{
      callback(err,result);
    });
  },
  getCategoriesById(id,callback){
    let sql =`SELECT * FROM categories WHERE id=${id}`;
    connection.query(sql,(err,result)=>{
      callback(err,result[0]);
    });
  }
};